#ifndef MYMESSAGEBOX_H
#define MYMESSAGEBOX_H

#include <QWidget>
#include <QPushButton>
#include <QMouseEvent>

namespace Ui {
class MyMessageBox;
}

class MyMessageBox : public QWidget
{
    Q_OBJECT

public:
    explicit MyMessageBox(QWidget *parent = nullptr);
    ~MyMessageBox();

    void setWindowTitle(const QString &title);
    void setText(const QString &text);

    void setButton();
    void setButton(const QString &button1);
    void setButton(const QString &button1, const QString &button2);
    void setButton(const QString &button1, const QString &button2, const QString &button3);

    int exec();

protected:
    // 用于拖动窗口的事件处理函数
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;

    void paintEvent(QPaintEvent *event) override;

private slots:
    void onSetButtonClicked();
    void onCloseButtonClicked();

private:
    Ui::MyMessageBox *ui;

    // 用于记录拖动时鼠标位置的成员变量
    QPoint m_dragPosition;

    // 添加用于判断是否点击标题栏的成员变量
    bool m_isTitleBarClicked = false;

    int result;

    QList<QPushButton*> buttons;
    QPushButton *createButton(const QString &text, int x, int y);

    // 设置每个按钮的样式
    QString buttonStyle = R"(
        QPushButton {
            border: 2px solid #55aaff;
            background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #aaffff, stop:1 #00ffff);
            color: #00aaff;
            font-size: 20px;
            font-weight: 200;
            font-family: "华文琥珀";
            border-radius: 10px;
        }
        QPushButton:hover {
            background: #55aaff;
            color: #aaffff;
        }
        QPushButton:pressed {
            background: #55aaff;
            color: #aaffff;
        }
    )";
};

#endif // MYMESSAGEBOX_H
